<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>用户任务列表详情</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/wlzz/css/font.css">
    <link rel="stylesheet" href="/wlzz/css/xadmin.css">
    <script type="text/javascript" src="/wlzz/js/jquery.min.js"></script>
    <script type="text/javascript" src="/wlzz/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/wlzz/js/xadmin.js"></script>
</head>

<body>
<div class="layui-tab layui-tab-card">
    <ul class="layui-tab-title">
        <li class="layui-this">已发布任务</li>
        <li>删除的任务</li>
    </ul>
    <div class="layui-tab-content" style="height: 100%;">
        <div class="layui-tab-item layui-show" id="task_exist_display">



            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="200">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th>任务id</th>
                    <th>任务标题</th>
                    <th>任务内容(省略图片)</th>
                    <th>评论数</th>
                    <th>点赞数</th>
                </tr>
                </thead>
                <tbody id="exist_display">

                </tbody>
            </table>



            <div id="task_exist" style="text-align: center"></div>
        </div>
        <div class="layui-tab-item"  id="task_delete_display">


            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="200">
                    <col>
                </colgroup>
                <thead>
                <tr>
                    <th>任务id</th>
                    <th>任务标题</th>
                    <th>任务内容(省略图片)</th>
                    <th>评论数</th>
                    <th>点赞数</th>
                </tr>
                </thead>
                <tbody id="delete_display">

                </tbody>
            </table>



            <div id="task_delete" style="text-align: center"></div>
        </div>
    </div>
</div>
</body>
<script>
    function reload_task(page,size,status,userid){
        $.post("/wlzz/backstage/taskForUser",
                {page:page,size:size,status:status,user_id:userid},function(data){
                    console.log(data);
                    if(data.code==0){
                        var dataList = data.data.dataList;
                        var allContent = "";
                        for(var i = 0;i<dataList.length;i++){
                            var content = ' <tr>'+
                                    '                    <td>'+dataList[i].task._id+'</td>'+
                                    '                    <td>'+dataList[i].task.title+'</td>'+
                                    '                    <td>'+dataList[i].task.content+'</td>'+
                                    '                    <td>'+dataList[i].commentCount+'</td>'+
                                    '                    <td>'+dataList[i].love+'</td>'+
                                    // '                    <td>'+(status==0?"删除":"恢复")+'</td>'+
                                    '                </tr>';
                            allContent = allContent+content;
                        }
                        if(status==0){
                            document.getElementById("exist_display").innerHTML=allContent;
                        }else if(status==1){
                            document.getElementById("delete_display").innerHTML=allContent;
                        }

                    }else{
                        layer.close(index);
                        layer.msg(data.msg, {icon: 5});
                    }
            });
    }

    layui.use(['laypage', 'layer'], function() {
        var laypage = layui.laypage
                , layer = layui.layer;
        var laypage = layui.laypage
        laypage.render({
            elem: 'task_exist'
            , count: ${exist_number!""}
            , layout: ['count', 'page']
            , limit: 5
            , jump: function (obj) {
                reload_task(obj.curr,obj.limit,0,${user_id});
            }
        });

        laypage.render({
            elem: 'task_delete'
            , count: ${delete_number!""}
            , layout:  ['count', 'page']
            , limit: 5
            , jump: function (obj) {
                // console.log(obj)
                // console.log(obj.curr); //得到当前页，以便向服务端请求对应页的数据。
                // console.log(obj.limit); //得到每页显示的条数
                reload_task(obj.curr,obj.limit,1,${user_id});
            }
        });
    });
</script>
</html>